
import cn.ac.iie.pre.parser.get.ReadFileThread;
import cn.ac.iie.pre.parser.get.ReadRecordThread;
import cn.ac.iie.pre.parser.global.GlobalParas;
import cn.ac.iie.pre.parser.put.SendMQThread;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * Created by Black-Laptop on 7/11/2017.
 */
public class test {
    static final Logger LOG=LoggerFactory.getLogger(test.class);
    public static GlobalParas globalParas = null;
    
    public static void main(String args[]) throws ConfigurationException {
        GlobalParas.getIstance(GlobalParas.DEFAULT_CONFIGURATION);
        PropertyConfigurator.configure(ClassLoader.getSystemClassLoader().getResource(globalParas.LOG4_CONFIGURATION));
        
        Thread getThread = new Thread(new ReadFileThread(), "file list get thread");
        getThread.start();
        LOG.info("get file list thread start");
        
        ExecutorService readRecordPool = Executors.newFixedThreadPool(GlobalParas.READ_RECORD_THREAD_NUM);
        ReadRecordThread readRecordThread = new ReadRecordThread();
        for (int i = 0; i < GlobalParas.READ_RECORD_THREAD_NUM; i++) {
            readRecordPool.execute(readRecordThread);
        }
        LOG.info("get record list threads start, num : "+GlobalParas.READ_RECORD_THREAD_NUM);
        
        for(Object msgType:GlobalParas.MSG_TYPES_NAME){
            Thread sendThread=new Thread(new SendMQThread(msgType.toString()),"send msg to mq, msgType: "+msgType.toString());
            sendThread.start();
            LOG.info("send msg to mq thread start, msgType: "+msgType.toString());
        }
    }
}
